<html>
<head>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script>
var t = async_test("window.stop() can stop loading of multipart images " +
                   "after <img>'s onload and " +
                   "after one more part loaded after onload.");

function callStop()
{
    const url = "resources/multipart.php?interval=1&loop=1&img1=2x2-green.png&img2=abe.png&label=2";
    if (window.internals) {
        assert_true(internals.isLoading(url), "The image should be loading before window.stop().");
    }
    window.stop();
    window.setTimeout(t.step_func(function() {
        if (window.internals) {
            assert_false(internals.isLoading(url), "The image should not be loading after window.stop().");
        }
        t.done();
    }), 100);
}

function firstPartLoaded()
{
    setTimeout(t.step_func(callStop), 1500);
}
</script>
</head>
<body>
<!-- |label| is added to avoid interaction between stop-loading* tests -->
<img id=testingImage src="resources/multipart.php?interval=1&loop=1&img1=2x2-green.png&img2=abe.png&label=2" onload="firstPartLoaded()">
</body>
</html>
